package top.luckyluxcis.util;

import lombok.experimental.UtilityClass;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @author Zhuang
 * @since 2023/9/25
 */
@UtilityClass
public class Base64Util {
    public static String encode(String content) {
        byte[] encodedBytes = Base64.getEncoder().encode(content.getBytes(StandardCharsets.UTF_8));
        return new String(encodedBytes, StandardCharsets.UTF_8);
    }

    public static String decode(String content) {
        byte[] decodedBytes = Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8));
        return new String(decodedBytes, StandardCharsets.UTF_8);
    }
}
